<template>
 <view class="wrapper">
	 <view class="goodContainer">
		 <view class="searchInput">
		 	<view class="goodFilter">
		 		<uniIcon type="search" size="14" style="line-height: 50rpx;margin-left: 10rpx;margin-right: 10rpx;color: #a7aab3;" /><input
		 		 placeholder="请输入单据编号" class="searchOption" v-model="inputStr"></input>
		 		<button class="searchBt" @tap="suosuo()">查询</button>
		 	</view>
		 	<view class="searchOptions">
		 		<!-- <button class="giveSong"></button> -->
		 		<button class="getPicture" @tap="tel()"></button>
		 	</view>
		 </view>
	 </view>
	 <view class="data-contain">
		 <view class="data-item" v-for="(item,index) in isPayList" :key='item.BillID' >
			 <view @tap="selectOrder(index)">
			 <view class="data-item-title">
				 编号:{{item.BillNo}}
			 </view>
			 <view class="data-item-itemName">单据总金额:{{item.Amount}}</view>
			 <view class="data-item-itemName">已结算金额:{{item.pamount}}</view>
			 <view class="data-item-itemName">未结算金额:{{item.Total}}</view>
			 </view>
			 <view class="data-item-itemInput">
				 <text>本次计算额:</text>
				 <input type="number" placeholder="输入计算额" v-model="item.payCount" />
			 </view>
		 </view>
	 </view>
 </view>
</template>
<script>
	import uniIcon from '@/components/uni-icon/uni-icon.vue';
	import * as Api from '@/syApis/syAddOrder/syaddApis.js'
	export default{
		components: {
			uniIcon
		},
		created() {
			
		},
		data(){
			return {
				//搜索框的条件
				inputStr: "",
				ClientId:0,
				//是否付款单 0是 1否
				IsPay:0,
				//付款单还是收款单的数组
				isPayList:[]
			}
		},
		onLoad(options) {
			this.ClientId = options.ClientId;
			this.IsPay = options.IsPay;
			uni.showLoading({
				title:"加载中....",
					mask:false
			})
			if(options.IsPay==0){
				uni.setNavigationBarTitle({
				title:"查询收款单"
			})
				this.Get_Receiv_Bill();
			}else{
				uni.setNavigationBarTitle({
					title:"查询付款单"
				})
				this.GetPayBill();
				
			}
		
			
			
		},
		methods:{
			// 搜索
			suosuo(){
				
			},
			//选中单据
			selectOrder(index){
				var selectOrder = this.isPayList[index];
				this.$eventHub.$emit('fires', JSON.stringify(selectOrder));
				uni.navigateBack({
					delta: 1
				})
			},
			GetPayBill(Filter){
				let data = {
					ClientID:this.ClientId
				}
				var self = this;
				Api.GetPayBill(data,function(res){
					uni.hideLoading();
					if(res.state){
						if(res.data.ErrorMsg=='获取登录信息失败'){
							
						}else if(res.data.ErrorMsg!=''){
							Api.showTip(res.data.ErrorMsg);
						}else{
							if(res.data.ResultMsg.length==0){
								Api.showTip("查无数据");
							}else{
								Api.showTip("加载成功");
							}
							res.data.ResultMsg.forEach((item,index)=>{
								item.payCount = 1;
							});
							self.isPayList = res.data.ResultMsg;
						}
					}else{
							uni.hideLoading();
						Api.showTip("服务器开小差了");
					}
				})
			},
			Get_Receiv_Bill(){
				let data = {
					ClientID:this.ClientId
				}
				var self = this;
				Api.GetReceivBill(data,function(res){
					uni.hideLoading();
					if(res.state){
						if(res.data.ErrorMsg=='获取登录信息失败'){
							
						}else if(res.data.ErrorMsg!=''){
							Api.showTip(res.data.ErrorMsg);
						}else{
							if(res.data.ResultMsg.length==0){
								Api.showTip("查无数据");
							}else{
								Api.showTip("加载成功");
							}
							res.data.ResultMsg.forEach((item,index)=>{
								item.payCount = 1;
							});
							self.isPayList = res.data.ResultMsg;
						}
					}else{
							uni.hideLoading();
						Api.showTip("服务器开小差了");
					}
				})
			}
		}
	}
</script>
<style>
	@import url("./css/getpaybill.css");
</style>
